package ui;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.event.KeyEvent;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JSeparator;
import javax.swing.JToolBar;
import javax.swing.border.EtchedBorder;

public class menu extends JFrame {
	public menu() {
		JMenuBar mnubMain = new JMenuBar();//创建菜单栏类对象
		JMenu mnuFile = new JMenu("文件");
		JMenu mnuEdit = new JMenu("编辑");
		JMenu mnuHelp = new JMenu("帮助");
		mnubMain.add(mnuFile);
		mnubMain.add(mnuEdit);
		mnubMain.add(mnuHelp);
		//创建菜单项类对象，设置菜单项快捷键
		JMenuItem mnuiNew = new JMenuItem("新建",KeyEvent.VK_N);//快捷键Ctrl+N
		JMenuItem mnuiOpen = new JMenuItem("打开",KeyEvent.VK_O);
		JMenuItem mnuiSave = new JMenuItem("保存",KeyEvent.VK_S);
		JMenuItem mnuiExit = new JMenuItem("退出",KeyEvent.VK_E);
		//将菜单项加入菜单Edit
		mnuFile.add(mnuiNew);
		mnuFile.add(mnuiOpen);
		mnuFile.add(mnuiSave);
		mnuFile.add(new JSeparator());
		mnuFile.add(mnuiExit);
		JToolBar tbMain =new JToolBar();//创建工具栏对象
		tbMain.setBorder(new EtchedBorder());//加浮雕边框
		JButton btnFile = new JButton("页面");//创建按钮对象
		tbMain.add(btnFile);//将File按钮加入工具栏
		this.setJMenuBar(mnubMain);//将菜单条加入框架
		
		this.add(tbMain,BorderLayout.NORTH);//将工具栏布局在界面北边
		this.setVisible(true);
		this.setPreferredSize(new Dimension(400,400));
		this.pack();
	}
	
	public static void main(String[] args) {
		new menu();
	}

}
